@P

Category: Objects

Syntax:
@P object.property = value

Sets the specified object's property to value.

If object belongs to a built-in class, value must be of the appropriate type for the property. Setting a property may cause side effects, depending on the implementation of the class; for example, changing a button's Caption property causes the caption to change on screen. object.property may refer to nested object-type properties: $label.Font.Name

If object belongs to a user-defined class, the effect of @p depends on the property definition and which object is invoking @p:

Write specifier @p invoked by Effect
Omitted Any code value stored in the object's property data
NoWrite Any code Nothing happens
Writer method The object's own method value stored in the object's property data
Writer method Any method of another object, or any other code Writer method invoked with $0 = property, $1- = value

When setting an event handler property, you should usually use @E instead.

Example:
@p $form.Caption = My Form
@p $button.Font.Style = [fsBold]

// validating property values with a writer method
Class TMyClass
  Public Property Count write SetCount
  
  Private Method SetCount
    if $IsNumeric($1)
      // this sets the property data directly
      @p $Self.Count = $1
    else
      MessageBox Numbers only please!
    endif
  EndMethod
EndClass

@l $obj = $new(TMyClass)
// this invokes the writer method
@p $obj.Count = 5
// displays the error message box
@p $obj.Count = Dracula
// still displays 5
MessageBox $prop($obj.Count)

See also: @E, Prop


Next in "Objects": AddToSetProp
Previous in "Objects": @E-
Next by name: @S
Previous by name: @L
Up to all commands by name or commands and functions by category